package cn.tedu.wms.passport.controller;

import cn.tedu.wms.passport.pojo.dto.LoginLogAddNewDTO;
import cn.tedu.wms.passport.pojo.vo.LoginLogListItemVO;
import cn.tedu.wms.passport.service.ILoginLogService;
import cn.tedu.wms.passport.web.JsonResult;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Slf4j
@Api(tags = "06. 登录日志模块")
@RestController
@RequestMapping("/login-logs")
public class LoginLogController {

    @Autowired
    ILoginLogService loginLogService;

    @ApiOperation("添加日志")
    @ApiOperationSupport(order = 100)
    @PostMapping("/add-new")
    public JsonResult<Void> addNew(LoginLogAddNewDTO loginLogAddNewDTO) {
        loginLogService.addNew(loginLogAddNewDTO);
        return JsonResult.ok();
    }

    @ApiOperation("日志列表")
    @ApiOperationSupport(order = 420)
    @PostMapping("/list")
    public JsonResult<List<LoginLogListItemVO>> list() {
        List<LoginLogListItemVO> list = loginLogService.list();
        return JsonResult.ok(list);
    }

}
